<?php /*a:2:{s:68:"D:\phpStudy\WWW\tp5\application\admin\view\admin_tool\tool_list.html";i:1553181890;s:58:"D:\phpStudy\WWW\tp5\application\admin\view\admin\head.html";i:1550326401;}*/ ?>
 <!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>广州商学院lms-后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" type="text/css" href="/static/lib/layui/css/layui.css" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/js/jquery.js"></script>
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">器具管理</a>
        <a>
          <cite>器具列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div style="padding: 20px">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" method="get" action="">
            <input type="text" name="name" placeholder="请输入器具名称" autocomplete="off" class="layui-input">
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <?php if(app('session')->get('admin')): ?>
    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加用户','<?php echo url('tool_add'); ?>')"><i class="layui-icon"></i>添加
        </button>
        <span class="x-right" style="line-height:40px">共有数据：<?php echo htmlentities(count($tools)); ?> 条</span>
    </xblock>
    <?php endif; ?>
    <table class="layui-table">
        <thead>
        <tr>
            <?php if(app('session')->get('admin')): ?>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i
                        class="layui-icon">&#xe605;</i></div>
            </th>
            <?php endif; ?>
            <th>ID</th>
            <th>器具名称</th>
            <th>所属科室</th>
            <th>所属教师</th>
            <th>最大借出天</th>
            <th>器具类型</th>
            <th>状态</th>
            <?php if(app('session')->get('admin')): ?>
            <th>操作</th>
            <?php endif; ?>

        </thead>
        <tbody>
        <?php if(is_array($tools) || $tools instanceof \think\Collection || $tools instanceof \think\Paginator): $i = 0; $__LIST__ = $tools;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$tool): $mod = ($i % 2 );++$i;?>
        <tr>
            <?php if(app('session')->get('admin')): ?>
            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='<?php echo htmlentities($tool['id']); ?>'><i
                        class="layui-icon">&#xe605;</i></div>
            </td>
            <?php endif; ?>

            <td><?php echo htmlentities($tool['id']); ?></td>
            <td><?php echo htmlentities($tool['name']); ?></td>
            <td><?php echo htmlentities((isset($tool->lab->name) && ($tool->lab->name !== '')?$tool->lab->name:"暂无实验室信息")); ?></td>
            <td><?php echo htmlentities((isset($tool->lab->teacher->realname) && ($tool->lab->teacher->realname !== '')?$tool->lab->teacher->realname:"暂无教师姓名")); ?></td>
            <td><?php echo htmlentities($tool['num']); ?></td>
            <td>
                <?php echo !empty($tool['type']) ? '大型器具' : '小型器具'; ?>
            </td>
            <td class="td-status">
                <?php switch($tool['statu']): case "0": ?> <button id="btn" class="layui-btn layui-btn-xs layui-btn-normal">在库</button><?php break; case "1": ?> <button id="btn" class="layui-btn layui-btn-xs layui-btn-danger">借出</button><?php break; case "2": ?> <button id="btn" class="layui-btn layui-btn-xs layui-btn-disabled">损坏</button><?php break; ?>
                <?php endswitch; ?>
            </td>
            <?php if(app('session')->get('admin')): ?>
            <td class="td-manage">
                <?php if($tool['statu'] == '0'): ?>
                <a title="设为损坏" onclick="change_statu(this,'<?php echo htmlentities($tool['id']); ?>')" href="javascript:;">
                    <i class="layui-icon ">&#xe631;</i>
                </a>
                <?php endif; ?>
                <a title="编辑" onclick="x_admin_show('编辑','<?php echo url('tool_update'); ?>/id/<?php echo htmlentities($tool['id']); ?>')" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" onclick="member_del(this,'<?php echo htmlentities($tool['id']); ?>')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
            <?php endif; ?>
        </tr>
        <?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
    </table>
    <div class="page">
        <?php echo $tools; ?>
    </div>
</div>
<script>
    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            //发异步删除数据
            $.post(
                "<?php echo url('tool_dele'); ?>",
                {id: id},
                function (data) {
                    if (data.statu == 200) {
                        $(obj).parents("tr").remove();
                        layer.msg(data.msg, {icon: 1, time: 1000});
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000});
                    }
                }
            )

        });
    }

    function change_statu(obj,id){
        layer.confirm('确定要将此器具设为损坏？',function(index){
            $.post(
                "<?php echo url('tool_disable'); ?>",
                {id:id},
                function(data){
                    if (data.statu==200) {
                        layer.msg(data.msg,{icon: 1,time:1000});
                        $(obj).parents("tr").find(".td-status").find('#btn').addClass('layui-btn-disabled').html('损坏');
                        $(obj).hide();
                    }else{
                        layer.msg(data.msg,{icon: 2,time:1000});
                    }
                }
                )
        })
    }

    function delAll(argument) {

        var data = tableCheck.getData();

        layer.confirm('确认要删除吗？' + data, function (index) {
            //捉到所有被选中的，发异步进行删除
            $.post(
                "<?php echo url('lab_dele'); ?>",
                {id: data},
                function (data) {
                    if (data.statu == 200) {
                        $(".layui-form-checked").not('.header').parents('tr').remove();
                        layer.msg(data.msg, {icon: 1, time: 1000});
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000});
                    }
                }
            )
        });
    }
</script>
</body>
</html>